﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;

namespace MVCCentral.Framework.Logger
{
    class EmailLogger : ILogger
    {
        #region ILogger Members

        public void Log(LogEventArgs args)
        {
            Email email = new Email();

            // these email addresses should come from the appSettings or database.
            email.ToList = ConfigurationManager.AppSettings["AdminEmail"];
            email.FromEmail = ConfigurationManager.AppSettings["AdminEmail"];
            email.isHTML = false;
            email.Subject = "An Exception occurred - " + DateTime.Now + " at " + ConfigurationManager.AppSettings["AppName"];
            email.MessageBody = args.Message;
            
            try
            {
                email.SendEmail(email);
            }
            catch (Exception)
            {

            }
        }

        #endregion
    }
}
